<!--
 * @Author: ZhaoZhiqi
 * @Date: 2024-04-28 15:10:57
 * @LastEditors: ZhaoZhiqi
 * @LastEditTime: 2024-09-03 17:05:31
 * @Description: 
 * @FilePath: \parking-mini\src\App.vue
-->
<script>
import Vue from "vue";
import { loginAPI, getInfoAPI } from "./api/api";

export default Vue.extend({
    mpType: "app",
    onLaunch() {},
    onShow() {},
    onHide() {},
    computed: {},
    globalData: {
        env: __wxConfig.envVersion === "release" ? "prod" : "test", // 开发版、体验版走测试，正式版走生产
        isProd: __wxConfig.envVersion === "release" ? true : false,
        globalInfo: null,
        imgs: {
            reset_location: "https://www.jfparking.com/wl/wlProfile/mini/2024/08/16/4b4690b4-d3bc-4c75-a011-44d996566947.png",
            logo: "https://www.jfparking.com/wl/wlProfile/mini/2024/06/14/079f0adf-8b70-4078-8dc7-3338c6a19b32.png",
            monthly_card: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/3301b50b-86c8-49c0-8203-334f4865cc13.png",
            numberplate_type1: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/d45bbb47-e505-4689-bd0d-b9e018352a10.png",
            numberplate_type2: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/0aa96889-3c10-4d89-967f-e9fe84636257.png",
            circle: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/b70adc96-72c5-4cd5-80b0-540ac1415ed2.png",
            vip_header: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/ed414fc0-be1c-4f4e-a041-a0d26d24c0c6.png",
            vip: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/336423cc-58ad-433b-a810-ebd781117045.png",
            grid1: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/0538f8e0-3b22-45b0-be1d-5125b016b0f0.png",
            grid2: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/58cef8c7-774b-4f98-a6ee-49e76d0f8c2f.png",
            grid3: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/14a8d349-0b7d-4e2f-810e-d6c9e2679615.png",
            grid4: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/28/b220531e-95c9-4023-9bcc-4217778ea918.png",
            grid5: "https://www.jfparking.com/wl/wlProfile/mini/2024/09/03/e15b480d-21e4-4aa8-b4ad-e17dfd200bfe.png",
            type1: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/a6221ef7-fdc8-46d3-90e1-72fb7a09a613.png",
            type2: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/ee916573-8f70-46b5-92d0-903bcf7d79e4.png",
            type3: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/c1c1f36f-d932-4a51-b6ca-46dfb8a73880.png",
            distance: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/effaf70a-1442-4e31-a437-55b373c32603.png",
            warning: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/1c35927f-e4ff-4206-99a5-9efd4fa2fc7f.png",
            plus: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/176837a7-f121-497c-876c-9fb42629928f.png",
            scan: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/001e9a57-dec9-4069-97d6-4a441ff45a51.png",
            delete: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/9d1c12fb-a0e1-469d-b949-c7d31d4bee60.png",
            search: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/04e1fccb-cde0-471d-8ce1-5a266117947a.png",
            select: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/b64d1968-5ce3-48c2-b866-9d33f7fbb0b3.png",
            backspace: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/49894280-7fce-464c-8dd8-a6b73a63fc72.png",
            close: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/1c9c2be4-2d85-4569-a9ab-444f5127a86c.png",
            close_gray: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/16/466b7b7f-606a-4d7e-ae86-c9acac1f6e50.png",
            close_white: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/16/c8bb37ba-af1a-4ef3-89bd-81872e37989e.png",
            marker: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/09c7910f-47c3-4c78-b25e-f528416cd8c8.png",
            marker_self: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/09/d382cc15-70f1-4879-bcb8-ae3daf66c4cf.png",
            location: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/13/b7a1edb1-aecf-4b22-82a7-1851453c31aa.png",
            contract: "https://www.jfparking.com/wl/wlProfile/mini/2024/08/30/6c5090d0-9e96-4fa0-bab1-058854e79dae.png",
            back: "https://www.jfparking.com/wl/wlProfile/mini/2024/05/28/3841e004-d020-4161-8b0d-c00dd0425454.png",
            vip_location: "https://www.jfparking.com/wl/wlProfile/mini/2024/07/26/533514ea-f227-48fd-aa38-8357b7620197.png",
            vip_price: "https://www.jfparking.com/wl/wlProfile/mini/2024/07/26/8eb2ee6a-8945-475e-bf76-932d1f1df70c.png"
        },
    },
    methods: {
        // 获取临时token 无需登录
        getTempToken() {
            return new Promise((resolve, reject) => {
                wx.login({
                    success: (res) => {
                        loginAPI({
                            code: res.code,
                        }).then((res) => {
                            let { openId, token } = res;
                            wx.setStorageSync("temp_token", token);
                            resolve(res);
                        });
                    },
                });
            });
        },
        // 登录
        login() {
            return new Promise((resolve, reject) => {
                wx.login({
                    success: (res) => {
                        loginAPI({
                            code: res.code,
                        }).then((res) => {
                            let { openId, token } = res;
                            wx.setStorageSync("parking_openid", openId);
                            resolve(res);
                        });
                    },
                });
            });
        },
        // 查询用户信息
        getInfo() {
            return new Promise((resolve, reject) => {
                getInfoAPI()
                    .then((res) => {
                        this.globalData.globalInfo = res;
                        resolve(res);
                    })
                    .catch((err) => {
                        reject(err);
                    });
            });
        },
    },
});
</script>

<style lang="scss">
/*每个页面公共css */
body {
    color: #333;
}
</style>
